import { category1List } from "@/api/product/attr";
import { Card, Form, Select } from "antd";
import React, { useEffect, useState } from "react";

export default function Attr() {
  // 1.定义一级分类的数据
  const [catrgory1List, setCategory1List] = useState([]);
  // 2.二级分类的数据
  const [catrgory2List, setCategory2List] = useState([]);
  // 3.三级分类的数据
  const [catrgory3List, setCategory3List] = useState([]);
  // 4.定义catrgoryId
  const [category1Id, setCategory1Id] = useState(1);

  // 函数方法--------------------------------------------
  const getCategory1List = async () => {
    const re = await category1List();
    console.log(re);
  };

  // 监听一级下拉框，收取到1id数据
  const getCatrgory1Id = (value: any) => {
    setCategory1Id(value);
    console.log("测试git推送功能");
  };

  useEffect(() => {
    getCategory1List();
  }, []);

  return (
    <>
      <Card bordered={false}>
        <Form name="categoryList" layout="inline">
          <Form.Item label="一级分类">
            <Select
              placeholder="请选择一级分类"
              style={{ width: 260 }}
              onChange={getCatrgory1Id}
            ></Select>
          </Form.Item>
          <Form.Item label="二级分类">
            <Select
              style={{ width: 260 }}
              placeholder="请选择二级分类"
            ></Select>
          </Form.Item>
          <Form.Item label="三级分类">
            <Select
              style={{ width: 260 }}
              placeholder="请选择三级分类"
            ></Select>
          </Form.Item>
        </Form>
      </Card>
    </>
  );
}
